A description of the prior art can be found in U.S. Pat. No. 6,076,141, issued Jun. 13, 2000, and entitled “Look-up switch accelerator and method of operating same.” The prior art that is described in the U.S. Pat. No. 6,076,141 enables the acceleration of a switch statement within a general purpose processor. It describes the ability to quickly perform simple, one-dimensional look-up switch statements in order to accelerate switch statements commonly found in some programming languages, such as JAVA.
The type of processor-coprocessor as described in U.S. Pat. No. 6,076,141 is quite useful for optimizing simple switch statements, where a given value is compared to achieve an exact match with one of many constant values. Table 1 below illustrates an exemplary set of switch statements that can be accelerated by the processor-coprocessor as described by the patent.
TABLE 1SWITCH (SHAPE)RECTANGLE: BEGIN . . .ENDCIRCLE: BEGIN . . .ENDTRIANGLE: BEGIN . . .ENDDEFAULT: BEGIN . . .END
In this example, the value stored in the variable ‘SHAPE’ must have an exact match with the constant values in each of the cases below it—‘RECTANGLE’, ‘CIRCLE’, etc.
For the switch statement above, the look-up switch accelerator will improve its execution performance. In other situations, where more than one dimension are required in making a decision on which code path to execute, it is entirely inadequate and provides no benefit at all.
An exemplary set of multi-dimensional switch statements that cannot be accelerated by the processor-coprocessor described in U.S. Pat. No. 6,076,141 is illustrated in Table 2 below.
TABLE 2IF ((SHAPE1 == CIRCLE) && (SHAPE2 == RECTANGLE) &&(SHAPE3 == OVAL)) BEGIN . . .ENDELSIF ((SHAPE2 == CIRCLE) && (SHAPE3 == RECTANGLE)) . . .ENDELSIF ((SHAPE1 == RECTANGLE) && (SHAPE4 == OVAL)) . . .ENDELSIF ((SHAPE2 == TRIANGLE) && (SHAPE4 == RECTANGLE)) . . .ENDELSIF ((SHAPE1 == PENTAGON) && (SHAPE4 == DECAGON)) . . .ENDELSE . . .END
The example of Table 2 above shows a very simple multi-dimensional decision. The code could be written as a switch statement in order to make use of the look-up switch accelerator, but it would be more efficient to keep the code as is and to execute each comparison sequentially as would be done in a conventional processor. The look-up switch accelerator is unable to handle simultaneous multi-dimensional comparisons.
Another significant shortfall of the processor-coprocessor in U.S. Pat. No. 6,076,141 is its inability to perform comparisons between dynamic values within the switch statement. The value being compared is always compared to constant values. It is not possible to perform what is shown in the Table 3 below.
TABLE 3// SHAPE1 and SHAPE2 are variablesSWITCH (SHAPE1)RECTANGLE:// This is OKENDSHAPE2:// SHAPE2 is a variable - it can't appear hereEND